<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教练管理</title>
    <link rel="stylesheet" href="../css/fore/order.css">
    <link rel="stylesheet" href="../css/fore/index.css">
    <script src="../js/jquery/2.0.0/jquery.min.js"></script>
    <link href="../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
    <script src="../js/bootstrap/3.3.6/bootstrap.min.js"></script>
    <script src="../js/vue.min.js"></script>
    <script src="../js/fetch.min.js"></script>
    <script src="../js/axios.min.js"></script>
    <script>
        function jump(e){
            var name = e.parentNode.className;
            console.log(name);
            if(name=="disabled" || name == "current"){
                return false;
            }
            else
                return true;
        }
    </script>
</head>
<body>
<div class="header">
    <div class="top">
        <div class="top-logo fl">
            <a id="logo" href="#nowhere" target="_blank"><img src="../img/car-logo.png" alt="" class="fl" style="margin-top: 20px;width: 45px"><span class="top-logo-text">后台教练管理页面</span></a>
        </div>
    </div>
    <div class="header-nav">
        <ul id="nav-list">
            <li class="nav-list-li"><a href="coach_admin.html">时间安排</a></li>
            <li class="nav-list-li"><a href="#">考试管理</a></li>
            <li class="nav-list-li"><a href="mystudent.html">我的学员</a></li>
        </ul>
    </div>
</div>

<div class="headlineC" id="allContent">
    <div class="headline">
        <div class="icon fl"><img src="../img/headline_icon.png" ></div>
        <h2 class="headline-title fl">上次考试学员</h2>
    </div>
    <div class="stream">
        <div class="item">
            <div class="date1 today">
                <span>所有学员</span>
            </div>
            <table class="list-time listPage table table-striped table-bordered table-hover">
                <thead>
                <tr class="success">
                    <th>姓名</th>
                    <th>电话</th>
                    <th>考试时间</th>
                    <th>本次考试状态</th>
                    <th>重设状态</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="s,index in ss">
                    <td>{{s.name}}</td>
                    <td>{{s.telephone}}</td>
                    <td>{{s.examInfo.date_}}</td>
                    <td v-if="s.examInfo.status == 1">通过考试</td>
                    <td v-if="s.examInfo.status == 0">未设定</td>
                    <td v-if="s.examInfo.status == -1">未通过</td>
                    <td><a class="glyphicon glyphicon-pencil" @click="reset(s.examInfo.id,s.id,s.examInfo.status,index)"></a></td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="pageDiv" align="center">
            <nav>
                <ul class="pagination">
                    <li :class="page.hasPrevious ? 'w' : 'disabled' " >
                        <a href="mystudent.html?start=0" onclick="return jump(this)">
                            <span>&laquo;</span>
                        </a>
                    </li>

                    <li :class="page.hasPrevious ? 'w' : 'disabled' " >
                        <a :href="'mystudent.html?start='+ (page.start-page.count)" onclick="return jump(this)">
                            <span>&lsaquo;</span>
                        </a>
                    </li>

                    <li v-for="i in page.totalPage"
                        :class="((i-1)*page.count)==page.start ? 'disabled' : 'w' ">
                        <a v-if="i*page.count-page.start<=20 && i*page.count-page.start>=-10"
                           :href="'mystudent.html?start=' + (i-1)*page.count"
                           :class="(i-1)*page.count==page.start ? 'current' : 'fa' "
                           onclick="return jump(this)">
                            <span>{{i}}</span>
                        </a>
                    </li>
                    <li :class="page.hasNext ? 'w' : 'disabled' ">
                        <a :href="'mystudent.html?start='+ (page.start+page.count)" onclick="return jump(this)">
                            <span>&rsaquo;</span>
                        </a>
                    </li>
                    <li :class="page.hasNext ? 'w' : 'disabled' " >
                        <a :href="'mystudent.html?start=' + page.last" onclick="return jump(this)">
                            <span>&raquo;</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>

</div>
<div class="footer">
    <p>
        Good CarTeacher©2018 | QQ:123456789
        <a href="https://baidu.com">|关于我们</a>
        <a href="https://sports.qq.com/">|驾校登录</a>
    </p>
</div>

<script>
    let url = "../admin_coach_listStudentByLastTime";
    new Vue({
        el: '#allContent',
        data: {
            ss: [],
            page: [],
            date: [],
            examType: []
        },
        mounted: function () {
            self = this;
            url += decodeURI(location.search);
            fetch(url).then(function (response) {
                response.json().then(function (jsonObject) {
                    console.log(jsonObject);
                    self.ss = jsonObject.ss;
                    self.page = jsonObject.page;
                }).catch(function (err) {
                    console.log("Fetch错误：" + err);
                })
            });
        },
        methods:{
            reset: function (eid, sid, status, index) {
                self  = this;
                url = "../admin_coach_resetStudentExamStatus?eid=" + eid + "&sid=" + sid +"&status=" + status;
                axios.get(url).then(function (response) {
                    let flag = response.data.flag;
                    if(flag == -11){
                        alert("已经通过考试无法重设");
                    }else if(flag == -22){
                        alert("考试未通过无法重设");
                    } else{
                        self.ss[index].examInfo.status = flag;
                        // self.$set(self.ss[index].examInfo.status,0,flag);
                    }
                })
            },
        }
    });
</script>
</body>
</html>